<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>    

<script type="text/javascript">
<!--
$(function(){
	getRanking();
});

function getRanking(){
	$.post('VUserRelation_ranking?begin=0&end=7', function(result){
		result = eval('('+result+')');
		if (result.success){
			ranking(result.children);			
		} else {
			alert('失败');
		}		
	});
}

/**
	关注某人
**/
function attention(u_id, u_name){	
	var url = 'UserRelation_attention?ur.UR_UED_ID='+u_id+'&u_name='+u_name;
	$.post(url, function(result){		
		result = eval('('+result+')');
		if (result.success){
			serverpush_alert('alert-success',
				'成功',
				result.msg,
			$('#dalert'));
			getRanking();			
		} else {
			serverpush_alert('alert-error',
				'错误',
				result.msg,
			$('#dalert'));			
		}
	});
}

function ranking(objs){
	var len = objs.length;
	var i;
	var s = '<table class="table table-striped">';
	for (i=0;i<len;i++){
		obj = objs[i];
		
		s = s + '<tr align="left">\n';
		s = s + '<td><span class="badge badge-info">'+(i+1)+'</span></td>\n';
		s = s + '<td><a href="#"><span class="label" style="font-size:6;">' + obj.VUUR_U_NICKNAME + '</span></a></td>\n';
//		s = s + '<a href="javascript:void(0);" onclick="attention(' + obj.VUUR_U_ID + ', \'' + obj.VUUR_U_NICKNAME + '\')" ><span class="label label-important">关注</span></a>\n';
		s = s + '<td><span class="label label-success">,有 ' + obj.VUUR_UED_CNT + ' 个人关注他(她)</span></td>\n';
		s = s + '</tr>';
	}
	s = s + '</table>';
	$('#uranking').html(s);
}
//-->
</script>
 
<div align="center">
<div id="dalert"></div>
	<h2>焦点人物</h2>
	<ul id="uranking">
	</ul>
</div>
